﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Marmat.Forms.Skin
{
    partial class Progress
    {
        /// <summary>
        /// 百分比（必填）可选值 0~100
        /// </summary>
        [Category("样式"), Description("百分比（必填）可选值 0~100")]
        [DefaultValue(0)]
        public int Percentage
        {
            get => this._percentage;
            set
            {
                int number = value > 100 ? 100 : value;
                number = number < 0 ? 0 : number;
                this._percentage = number;
                this.PercentageChange?.Invoke(this, EventArgs.Empty);
                this.Invalidate();
            }
        }
        private int _percentage;


        /// <summary>
        /// 进度条显示文字内置在进度条内 如果宽度不够则不显示
        /// </summary>
        [Category("样式"), Description("进度条显示文字内置在进度条内 如果宽度不够则不显示")]
        [DefaultValue(false)]
        public bool TextInside
        {
            get => _textInside;
            set
            {
                this._textInside = value;
                this.Invalidate();
            }
        }
        private bool _textInside;


        /// <summary>
        /// 是否开启圆角按钮，如果为true则 Circle 属性设置无效
        /// </summary>
        [Category("样式"), Description("是否开启圆角按钮，如果为true则 Circle 属性设置无效")]
        [DefaultValue(false)]
        public bool Round
        {
            get => this.round;
            set
            {
                if (this.round != value)
                {
                    this.round = value;
                    this.Invalidate();
                }
            }
        }
        private bool round;


        /// <summary>
        /// 背景色
        /// </summary>
        [DefaultValue(typeof(Color), "235, 238, 245")]
        public new Color BackColor
        {
            get => this._backColor;
            set
            {
                this._backColor = value;
                this.Invalidate();
            }
        }
        private Color _backColor = Configuration.DefaultTheme.BorderExtralight;


        [Category("样式"), Description("进度条颜色")]
        [DefaultValue(typeof(Color), "66, 158, 251")]
        public Color ProgressColor
        {
            get
            {
                Color result = this._progressColor;
                if (result == Configuration.DefaultTheme.Primary)
                {
                    switch (this.ThemeStyle)
                    {
                        case ThemeStyleEnum.Default:
                            result = Color.White;
                            break;
                        case ThemeStyleEnum.Primary:
                            result = Configuration.DefaultTheme.Primary;
                            break;
                        case ThemeStyleEnum.Success:
                            result = Configuration.DefaultTheme.Success;
                            break;
                        case ThemeStyleEnum.Info:
                            result = Configuration.DefaultTheme.Info;
                            break;
                        case ThemeStyleEnum.Warning:
                            result = Configuration.DefaultTheme.Warning;
                            break;
                        case ThemeStyleEnum.Danger:
                            result = Configuration.DefaultTheme.Danger;
                            break;
                    }
                }
                return result;
            }
            set
            {
                this._progressColor = value;
                this.Invalidate();
            }
        }
        private Color _progressColor = Configuration.DefaultTheme.Primary;



        /// <summary>
        /// 获取或设置组件的主题样式。
        /// </summary>
        [Category("样式"), Description("获取或设置组件的主题样式。")]
        [DefaultValue(typeof(ThemeStyleEnum), nameof(ThemeStyleEnum.Primary))]
        public ThemeStyleEnum ThemeStyle
        {
            get => _themeStyle;
            set
            {
                if (this._themeStyle != value)
                {
                    this._themeStyle = value;
                    this.Invalidate();
                }
            }
        }
        private ThemeStyleEnum _themeStyle = ThemeStyleEnum.Primary;


        /// <summary>
        /// 进度改变后执行
        /// </summary>
        [Category("样式"), Description("进度改变后执行")]
        public event EventHandler PercentageChange;

        // 获取百分比
        public delegate void PercentageChangeEvent(object Sneder);

        /// <summary>
        /// 获取控件默认大小
        /// </summary>
        protected override Size DefaultSize => new Size(100, 10);

    }
}
